package com.taotao.web;

import com.taotao.common.EasyUIResult;
import com.taotao.common.TaotaoResult;
import com.taotao.pojo.TbContent;
import com.taotao.service.TbContentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/content")
public class TbContentController {

    @Autowired
    private TbContentService tbContentService;

    /**
     * 查询content
     * @param categoryId
     * @param pageNum
     * @param pageSize
     * @return
     */
    @RequestMapping("/query/list")
    @ResponseBody
    public EasyUIResult getTbContentByCategoryId(Long categoryId, @RequestParam("page") int pageNum, @RequestParam("rows") int pageSize){
        EasyUIResult easyUIResult = tbContentService.getTbContentByCategoryIdList(categoryId, pageNum, pageSize);
        return easyUIResult;
    }

    /**
     * 新增content数据
     * @param tbContent
     * @return
     */
    @RequestMapping("/save")
    @ResponseBody
    public TaotaoResult saveTbContent(TbContent tbContent){
        TaotaoResult taotaoResult = tbContentService.saveTbContent(tbContent);
        return taotaoResult;
    }

    /**
     * 删除content数据
     * @param ids
     * @return
     */
    @RequestMapping("/delete")
    @ResponseBody
    public TaotaoResult deleteTbContent(Long[] ids){
        TaotaoResult taotaoResult = tbContentService.deleteTbContent(ids);
        return taotaoResult;
    }

    /**
     * 更新content数据
     * @param tbContent
     * @return
     */
    @RequestMapping("/edit")
    @ResponseBody
    public TaotaoResult updateTbContent(TbContent tbContent){
        TaotaoResult taotaoResult = tbContentService.updateTbContent(tbContent);
        return taotaoResult;
    }
}
